<?php

class UserRoleRecord extends TActiveRecord
{
	const TABLE = 'users_roles';
	
	// fields
	public $user_id;
	public $role_id;
	
	public function setUserId($user_id)   { $this->user_id = $user_id; }
	public function setRoleId($role_id)   { $this->role_id = $role_id; }
	
	public function getUserId()   { return $this->user_id; }
	public function getRoleId()   { return $this->role_id; }
	
	public function setData($user_id, $role_id)
	{
		$this->user_id = $user_id;
		$this->role_id = $role_id;
	}
	
	public function setDataByUserRoleRecord($record)
	{
		if($record instanceof UserRoleRecord)
		{
			$this->setData($record->getUserId(), $record->getRoleId());
		}
	}
	
	public function equals($userRoleRecord)
	{
		if($userRoleRecord instanceof UserRoleRecord)
		{
			return	$this->getUserId() == $userRoleRecord->getUserId()	&&
					$this->getRoleId() == $userRoleRecord->getRoleId();
		}
		return false;
	}
	
	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
}

?>